<?php
namespace Home\Controller;
use Think\Controller;
use Think\Page;
class IndexController extends Controller {
    public  function  index(){
      $goods1=M('goods')->order('id desc')->limit(4)->select();
      $goods2=M('goods')->order('id desc')->limit(4,8)->select();
      $this->assign('goods1',$goods1);
      $this->assign('goods2',$goods2);
      $this->display(); 
    }

    public  function news(){
         header('content-type:text/html;charset=utf8');
        $news_id=M('category')->where("name='新闻中心'")->field('id')->select();
        $news_id=$news_id[0]['id'];
        $where=array('cid'=>$news_id,'del'=>1);
        $count=M('article')->where($where)->count();//总条数
        $p=getpage($count,4);
        $news=M('article')->where($where)->order('id')->limit($p->firstRow, $p->listRows)->select();
        $s=0;
        foreach($news as $v){
           $news[$s]['remark']=htmlspecialchars_decode($v['remark']); 
           $s++;
        }
        //dump($p->show());exit;
        $this->assign('news',$news);
        $this->assign('page', $p->show()); // 赋值分页输出
        $this->display();
    }
     public  function new_content(){
        $new_id=I('get.a_id');
        $news_id=M('category')->where("name='新闻中心'")->field('id')->select();
        $news_id=$news_id[0]['id'];
        
        $date['id']=$new_id;
        $new_content=M('article')->where("id='$new_id' and cid='$news_id' and del=1")->select();
        $new_news=M('article')->where("del=1")->order('id desc')->limit(4)->select();
        $s=0;
        foreach($new_content as $v){
           $new_content[$s]['content']=htmlspecialchars_decode($v['content']); 
           $s++;
        }
        $this->assign('new',$new_content);
        $this->assign('new_news',$new_news);
        $this->display();
    }

    public  function style(){
        header('content-type:text/html;charset=utf8');
        $news_id=M('category')->where("name='团队风采'")->field('id')->select();
        $news_id=$news_id[0]['id'];
        $new_news=M('article')->where("del=1")->order('id desc')->limit(4)->select();
        $where=array('cid'=>$news_id,'del'=>1);
        $count=M('article')->where($where)->count();
        $p=getpage($count,4);
        $news=M('article')->where($where)->limit($p->firstRow, $p->listRows)->select();
        $s=0;
        foreach($news as $v){
           $news[$s]['remark']=htmlspecialchars_decode($v['remark']); 
           $s++;
        }
        //dump($p->show());exit;
        $this->assign('page',$p->show());
        $this->assign('new_news',$new_news);
        $this->assign('style',$news);
        $this->display();
    }
    public  function style1(){
        $new_id=I('get.a_id');
        $news_id=M('category')->where("name='团队风采'")->field('id')->select();
        $news_id=$news_id[0]['id'];
        
        $date['id']=$new_id;
        $new_content=M('article')->where("id='$new_id' and cid='$news_id' and del=1")->select();
        $new_news=M('article')->where("del=1")->order('id desc')->limit(4)->select();
        $s=0;
        foreach($new_content as $v){
           $new_content[$s]['content']=htmlspecialchars_decode($v['content']); 
           $new_content[$s]['remark']=htmlspecialchars_decode($v['remark']);
           $s++;
        }
        $this->assign('new',$new_content);

        $this->assign('new_news',$new_news);
        $this->display();
    }
    public function contact(){
        $new_news=M('article')->where("del=1")->order('id desc')->limit(4)->select();
        $this->assign('new_news',$new_news);
        $this->display();
    }
 }